package com.kaifamiao.www.demo.do0921;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;

public class FileInputStreamDemo03 {
    public static void main(String[] args) {

        File file = new File("E:\\kaifamiao\\workspace\\idea--space\\io\\file-input.txt");
        if (file.exists()&&file.isFile()){
            try (FileInputStream fis = new FileInputStream(file);){
                Charset gbk = Charset.forName("gbk");
                byte[] bytes = fis.readAllBytes();
                String str = new String(bytes,gbk);
                System.out.print(str);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }


        }
    }
}
